package org.wkg.lesson09;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class Demo_902 {

    public static void main(String[] args) throws InterruptedException {
        ExecutorService threadPool = Executors.newFixedThreadPool(3);

        for (int i = 0; i < 10; i++) {

            int taskId = i + 1;
            threadPool.submit(() -> {
                System.out.println("执行任务： " + taskId + "   线程名：" + Thread.currentThread().getName());
            });

            if (taskId % 2 == 0) {
                TimeUnit.SECONDS.sleep(1);
            }
        }
    }


}
